package org.yzh.commons.model;

import io.swagger.v3.oas.annotations.media.Schema;
import org.yzh.commons.model.enums.Role;

import java.time.Instant;

public class UserPrincipal {

    @Schema(description = "用户id")
    private final int id;
    @Schema(description = "角色")
    private final Role role;
    @Schema(description = "签发时间")
    private final Instant issuedAt;
    @Schema(description = "过期时间")
    private final Instant expiresAt;

    public UserPrincipal(int id, Role role, Instant issuedAt, Instant expiresAt) {
        this.id = id;
        this.role = role;
        this.issuedAt = issuedAt;
        this.expiresAt = expiresAt;
    }

    public int getId() {
        return id;
    }

    public Role getRole() {
        return role;
    }

    public Instant getIssuedAt() {
        return issuedAt;
    }

    public Instant getExpiresAt() {
        return expiresAt;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder(120);
        sb.append("UserPrincipal{id=").append(id);
        sb.append(", role=").append(role);
        sb.append(", issuedAt=").append(issuedAt);
        sb.append(", expiresAt=").append(expiresAt);
        sb.append('}');
        return sb.toString();
    }
}